<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <ul>
            <li><a href='/home'>home</a></li>
            <li><a href='/about'>about</a></li>
    
            <div id="routeView"></div>
        </ul>
    </ul>
    <script>
        let routerView = routeView
        window.addEventListener('DOMContentLoaded', onLoad)
        window.addEventListener('popstate', ()=>{
            routerView.innerHTML = location.pathname
        })
        function onLoad () {
            console.log(location.pathname);
            routerView.innerHTML = location.pathname
            var linkList = document.querySelectorAll('a[href]')
            linkList.forEach(el => el.addEventListener('click', function (e) {
                e.preventDefault()
                history.pushState(null, '', el.getAttribute('href'))
                routerView.innerHTML = location.pathname
            }))
        }
    
    </script>
</body>
</html>